package com.mcxx.modules.temporary.controller;

import com.mcxx.config.CheckOrderUse;
import com.mcxx.modules.minimumliving.service.RecheckService;
import com.mcxx.modules.temporary.service.TempBackLogService;
import com.mcxx.modules.miniSalvation.check.service.read.CheckReadService;
import com.mcxx.modules.miniSalvation.check.service.write.CheckWriteService;
import com.mcxx.modules.miniSalvation.family.entity.BankEntity;
import com.mcxx.modules.miniSalvation.family.entity.OrganizationEntity;
import com.mcxx.modules.miniSalvation.family.service.read.BankReadService;
import com.mcxx.modules.miniSalvation.family.service.read.OrganizationReadService;
import com.mcxx.modules.miniSalvation.order.dto.*;
import com.mcxx.modules.miniSalvation.order.service.read.InHouseReadService;
import com.mcxx.modules.temporary.order.dto.TmpApprovalDTO;
import com.mcxx.modules.temporary.order.dto.TmpAuditDTO;
import com.mcxx.modules.temporary.order.entity.TmpOrderDetailEntity;
import com.mcxx.modules.temporary.order.param.TemporaryOrderParam;
import com.mcxx.modules.temporary.order.service.read.TmpOrderReadService;
import com.mcxx.modules.temporary.salary.service.write.TmpFamilySalaryWriteService;
import com.mcxx.service.DefaultRestService;
import com.mcxx.util.Constant;
import com.mcxx.util.FileExportUtil;
import com.yinhai.ta404.component.audit.vo.ExcelInfo;
import com.yinhai.ta404.core.restservice.annotation.RestService;
import com.yinhai.ta404.core.restservice.requestbean.PageParam;
import com.yinhai.ta404.core.restservice.resultbean.Page;
import com.yinhai.ta404.core.security.vo.UserAccountVo;
import com.yinhai.ta404.core.validate.annotation.V;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Slf4j
@Validated
@Api("临时救助待办列表")
@RestService({"temporary/salvation/backlog/v2"})
public class TempSalvationBacklogController extends DefaultRestService {

    @Autowired
    private TmpOrderReadService tmpOrderReadService;
    @Autowired
    private TempBackLogService tempBackLogService;
    @Autowired
    private InHouseReadService inHouseReadService;
    @Autowired
    private OrganizationReadService organizationReadService;
    @Autowired
    private BankReadService bankReadService;
    @Autowired
    private TmpFamilySalaryWriteService tmpFamilySalaryWriteService;
    @Autowired
    private CheckReadService checkReadService;
    @Autowired
    private CheckWriteService checkWriteService;
    @Autowired
    private RecheckService recheckService;




    @PostMapping("getTownSalvationTodoList")
    @ApiOperation("查询乡镇待办列表")
    public void getTownSalvationTodoList(TemporaryOrderParam param, PageParam pageParam){

        param.setBusinessType(Constant.BusinessCode.LINSHI);
        param.setRecordFlag("'01','03'");
        Page page = tmpOrderReadService.getTownSalvationTodoList(param, pageParam, getCurUserAccount());
        this.setPageBean(page);
    }



    @PostMapping("sendCheck")
    @ApiOperation("发起核对")
    public void sendCheck(@V("notnull") @RequestPart List<CheckDTO> checkDTOList){
        log.info("发起核对，参数是：{}", checkDTOList);
        Map<String, List<String>> rstMap = tempBackLogService.sendCheck(checkDTOList, getCurUserAccount(), Constant.BusinessCode.LINSHI);
        setData(this.packageSendCheckRst(rstMap));
        log.info("发起核对，结果是：{}", rstMap);
    }

    @PostMapping("testCheck")
    @ApiOperation("发起核对")
    public void test(@RequestBody List<CheckDTO> checkDTOList){
        log.info("发起核对，参数是：{}", checkDTOList);
        Map<String, List<String>> rstMap = tempBackLogService.sendCheck(checkDTOList, getCurUserAccount(), Constant.BusinessCode.LINSHI);
        setData(this.packageSendCheckRst(rstMap));
        log.info("发起核对，结果是：{}", rstMap);
    }


    private String packageSendCheckRst( Map<String, List<String>> rstMap){
        StringBuffer rstMsg = new StringBuffer();
        if(rstMap.containsKey("noExistCert") == false && rstMap.containsKey("canNotSendCheck") == false
                && rstMap.containsKey("imperfectInfo") == false && rstMap.containsKey("noReport") == false
                && rstMap.containsKey("success") ){
            return rstMap.get("checkMsg").get(0);
        }else if(rstMap.containsKey("noExistCert") == false && rstMap.containsKey("canNotSendCheck") == false
                && rstMap.containsKey("imperfectInfo") == false  && rstMap.containsKey("noReport") == false
                && rstMap.containsKey("fail")){
            return "操作失败";
        }
        if(rstMap.containsKey("imperfectInfo")){
            rstMsg.append("【").append(String.join(",",rstMap.get("imperfectInfo"))).append("】户主信息未完善，不能发起核对；\n");
        }
        if(rstMap.containsKey("noCompleteMember")){
            rstMsg.append("【").append(String.join(",",rstMap.get("noCompleteMember"))).append("】成员信息未完善，不能发起核对；\n");
        }
        if(rstMap.containsKey("noReport")){
            rstMsg.append("【").append(String.join(",",rstMap.get("noReport"))).append("】已发起核对且无核对报告返回，不能继续发起核对；");
        }
        if(rstMap.containsKey("noExistCert")){
            rstMsg.append("【").append(String.join(",",rstMap.get("noExistCert"))).append("】不存在救助申请家庭经济状况核对授权书/户口本，不能发起核对；\n");
        }
        if(rstMap.containsKey("noIdCertFamilyIdcard")){
            rstMsg.append("【").append(String.join(",",rstMap.get("noIdCertFamilyIdcard"))).append("】成员身份证未上传，不能发起核对；\n");
        }
        if(rstMap.containsKey("noBackUpFamilyIdcard")){
            rstMsg.append("【").append(String.join(",",rstMap.get("noBackUpFamilyIdcard"))).append("】未完成信息备份，不能发起核对；\n");
        }
        if(rstMap.containsKey("canNotSendCheck")){
            rstMsg.append("【").append(String.join(",",rstMap.get("canNotSendCheck"))).append("】核对中/已发起核对，不能发起核对；\n");
        }
        if(rstMap.containsKey("success")){
            rstMsg.append("【").append(String.join(",",rstMap.get("success"))).append("】发起成功；\n");
        }
        if(rstMap.containsKey("checkMsg")){
            rstMsg.append(rstMap.get("checkMsg").get(0));
        }
        return rstMsg.toString();
    }








    @PostMapping("isCanInHouse")
    @ApiOperation("判读是否可以发起入户调查")
    public void isCanInHouse(String orderId){
        log.info("判读是否可以发起入户调查，参数orderId是：{}", orderId);
        tempBackLogService.isCanInHouse(orderId, getCurUserAccount());
        log.info("判读是否可以发起入户调查，结果：{}", true);
        setData(true);
    }



    @PostMapping("getInHouseRecord")
    @ApiOperation("根据orderId查询入户调查记录（乡镇/区县）")
    public void getInHouseRecord(@V("notnull") String orderId, @V("notnull") String areaLevel){
        log.info("根据orderId查询入户调查记录，参数是：{}", orderId);
        OrderInHouseDTO orderInHouseDTO = tmpOrderReadService.queryLastInHouseRecord(orderId, areaLevel);
        setData(orderInHouseDTO);
        log.info("根据orderId查询入户调查记录，结果是：{}", orderInHouseDTO);
    }





    @GetMapping("getInHouseListByOrderId")
    @ApiOperation("根据orderId查询入户调查记录列表（乡镇/区县）")
    public void getInHouseListByOrderId(@V("notnull") String orderId){
        setData("data", inHouseReadService.selectListByOrderId(orderId, getCurUserAccount().getAreaLevel()));
    }


    @PostMapping("saveInHouseRecord")
    @ApiOperation("保存入户调查信息")
    public void saveInHouseRecord(OrderInHouseDTO orderInHouse, @RequestPart List<String> orderCertIdList){
        log.info("保存入户调查信息，参数是：{}", orderInHouse);
        orderInHouse.setCheckResult(Constant.BusinessCode.LINSHI);
        String inHouseId = tempBackLogService.saveInHouseRecord(orderInHouse, orderCertIdList, getCurUserAccount(),"0");
        setData(inHouseId);
        log.info("保存入户调查信息，结果是：{}", inHouseId);
    }


    @PostMapping("confirmInHouseRecord")
    @ApiOperation("确认入户调查信息")
    public void confirmInHouseRecord(OrderInHouseDTO orderInHouse, @RequestPart List<String> orderCertIdList){
        log.info("确认入户调查信息，参数是：{}", orderInHouse);
        orderInHouse.setCheckResult(Constant.BusinessCode.LINSHI);
        String inHouseId = tempBackLogService.saveInHouseRecord(orderInHouse, orderCertIdList, getCurUserAccount(),"1");
        setData(inHouseId);
        log.info("确认入户调查信息，结果是：{}", inHouseId);
    }


    @PostMapping("modifyInHouseRecord")
    @ApiOperation("更新入户调查信息")
    public void modifyInHouseRecord(@V("notnull") OrderInHouseDTO orderInHouse, @V("notnull") @RequestPart List<String> orderCertIdList){
        log.info("更新入户调查信息，参数是：{}", orderInHouse);
        orderInHouse.setCheckResult(Constant.BusinessCode.LINSHI);
        int rstFlag =  tempBackLogService.modifyInHouseRecord(orderInHouse,orderCertIdList, getCurUserAccount());
        setData(true);
        log.info("保存入户调查信息，结果是：{}", rstFlag);
    }






    @PostMapping("getOldAgeHomes")
    @ApiOperation("根据地区读取相应的机构")
    public void getOldAgeHomes(){
        log.info("根据地区读取相应的机构");
        String areaCode = getCurUserAccount().getAreaCode().substring(0,6);
        List<OrganizationEntity> orgList = organizationReadService.getOldAgeHomesByAreaCode(areaCode);
        setData(orgList);
        log.info("根据地区读取相应的机构,结果是：{}", orgList);
    }







    @PostMapping("isCanAuditOrApproval")
    @ApiOperation("判断是否可以走审核流程")
    public void isCanAuditOrApproval(@V("notnull") String orderId, String familyId, @V("notnull") String curBizState){
        log.info("判断是否可以走审核流程，参数是：{}", orderId);
        String rst = tempBackLogService.isCanAuditOrApproval(orderId, familyId, curBizState, getCurUserAccount());
        setData(rst);
        log.info("判断是否可以走审核流程，结果是：{}", rst);

    }

    @PostMapping("isCanApproval")
    @ApiOperation("判断是否可以走审批流程")
    public void isCanApproval(@V("notnull") String orderId, String familyId, @V("notnull") String curBizState){
        log.info("判断是否可以走审批流程，参数是：{}", orderId);
        tempBackLogService.isCanApprove(orderId, familyId,getCurUserAccount());
        setData(true);
        log.info("判断是否可以走审批流程，结果是：{}", true);

    }


    @PostMapping("isCanFirstAudit")
    @ApiOperation("判断是否可以走初审流程")
    public void isCanFirstAudit(@V("notnull") String orderId, String familyId){
        log.info("判断是否可以走初审流程，参数是：{},{}", orderId,familyId);
        tempBackLogService.isCanFirstAudit(orderId, familyId,getCurUserAccount());
        log.info("判断是否可以走初审流程，结果是：{}", 1);
    }

    @PostMapping("isCanSalvationAudit")
    @ApiOperation("判断是否可以走审核流程")
    public void isCanSalvationAudit(@V("notnull") String orderId, String familyId){
        log.info("判断是否可以走初审流程，参数是：{}", orderId);
        tempBackLogService.isCanSalvationAudit(orderId, familyId,getCurUserAccount());
        log.info("判断是否可以走初审流程，结果是：{}", 1);
    }

    @PostMapping("getFirstSalvationAudit")
    @ApiOperation("查询审核信息")
    public void getFirstSalvationAudit(@V("notnull") String familyId, @V("notnull") String orderId,@V("notnull") String mainReason) {
        log.info("查询审核信息，参数是：{}", orderId);
        TmpAuditDTO tmpAuditDTO = tempBackLogService.getFirstSalvationAudits(familyId, orderId,mainReason);
        setData(tmpAuditDTO);
        log.info("查询审核信息，结果是：{}", tmpAuditDTO);
    }


    @PostMapping("getSalvationAudit")
    @ApiOperation("查询审核信息")
    public void getSalvationAudit(@V("notnull") String familyId, @V("notnull") String orderId,@V("notnull") String mainReason) {
        log.info("查询审核信息，参数是：{}", orderId);
        TmpAuditDTO tmpAuditDTO = tempBackLogService.getSalvationAudits(familyId, orderId,mainReason);
        setData(tmpAuditDTO);
        log.info("查询审核信息，结果是：{}", tmpAuditDTO);
    }


    @PostMapping("calcFamilySalaryBySalvationRule")
    @ApiOperation("根据救助金计算方式救助金额")
    public void calcFamilySalaryBySalvationRule(@V("notnull") TmpAuditDTO tmpAuditDTO) {
        log.info("根据救助金计算方式救助金额，参数是：{}", tmpAuditDTO);
        tmpAuditDTO.setBusinessType(Constant.BusinessCode.LINSHI);
        tmpAuditDTO = tempBackLogService.calcFamilySalaryBySalvationRule(tmpAuditDTO, getCurUserAccount());
        setData(tmpAuditDTO);
        log.info("根据救助金计算方式救助金额，结果是：{}", tmpAuditDTO);
    }


    @CheckOrderUse(value = 0,type = "object",notes = "审核保存")
    @PostMapping("saveFirstAudit")
    @ApiOperation("暂存初审信息")
    public void saveFirstAudit(@RequestBody @V("notnull") TmpAuditDTO tmpAuditDTO) {
        log.info("暂存审核信息，参数是：{}", tmpAuditDTO);
        tmpAuditDTO.setBusinessType(Constant.BusinessCode.LINSHI);
        tmpAuditDTO.setAreaCode(getCurUserAccount().getAreaCode());
        tempBackLogService.saveFirstAudit(tmpAuditDTO, getCurUserAccount());
        setData(true);
        log.info("暂存审核信息，结果是：{}", true);
    }

    @CheckOrderUse(value = 0,type = "object",notes = "审核保存")
    @PostMapping("confirmFirstAudit")
    @ApiOperation("确认初审信息")
    public void confirmFirstAudit(@RequestBody @V("notnull") TmpAuditDTO tmpAuditDTO) {
        log.info("确认初审信息，参数是：{}", tmpAuditDTO);
        tmpAuditDTO.setBusinessType(Constant.BusinessCode.LINSHI);
        tmpAuditDTO.setAreaCode(getCurUserAccount().getAreaCode());
        tempBackLogService.confirmFirstAudit(tmpAuditDTO, getCurUserAccount());
        setData(true);
        log.info("确认初审信息，结果是：{}", true);
    }


    @CheckOrderUse(value = 0,type = "object",notes = "审核保存")
    @PostMapping("saveSalvationAudit")
    @ApiOperation("保存审核信息")
    public void saveSalvationAudit(@RequestBody @V("notnull") TmpAuditDTO tmpAuditDTO) {
        log.info("保存审核信息，参数是：{}", tmpAuditDTO);
        tmpAuditDTO.setBusinessType(Constant.BusinessCode.LINSHI);
        tmpAuditDTO.setAreaCode(getCurUserAccount().getAreaCode());
        tempBackLogService.saveSalvationAudit(tmpAuditDTO, getCurUserAccount());
        setData(true);
        log.info("保存审核信息，结果是：{}", true);
    }


    @CheckOrderUse(value = 0,type = "object",notes = "审核确认")
    @PostMapping("confirmSalvationAudit")
    @ApiOperation("审核确认")
    public void confirmSalvationAudit(@RequestBody @V("notnull") TmpAuditDTO tmpAuditDTO) {
        log.info("审核保存，参数是：{}", tmpAuditDTO);
        tmpAuditDTO.setBusinessType(Constant.BusinessCode.LINSHI);
        tmpAuditDTO.setAreaCode(getCurUserAccount().getAreaCode());
        String remindBankInfo = tempBackLogService.submitSalvationRequest(tmpAuditDTO, getCurUserAccount());
        setData(remindBankInfo);
        log.info("审核保存，结果是：{}", true);
    }


    @PostMapping("getOnethingCheckType")
    @ApiOperation("查询是否走一事一议流程")
    public void getOnethingCheckType(TmpAuditDTO auditDTO) {
        log.info("查询是否走一事一议流程，参数是：{}", auditDTO);
        tmpFamilySalaryWriteService.getOnethingCheckType(getCurUserAccount(), auditDTO);
        setData(auditDTO.getOnethingCheckType());
        log.info("查询是否走一事一议流程，结果是：{}", auditDTO.getOnethingCheckType());
    }


    @PostMapping("getBankInfo")
    @ApiOperation("根据户主的身份证拿到对应的银行卡信息")
    public void getBankInfo(String familyId, String memberId){
        log.info("根据户主的身份证拿到对应的银行卡信息,参数{},{}", familyId, memberId);
        BankEntity bankEntity = bankReadService.getBankByFamilyId(familyId, memberId, Constant.BusinessCode.LINSHI);
        setData(bankEntity);
        log.info("根据户主的身份证拿到对应的银行卡信息,结果{}", bankEntity);
    }


    @PostMapping("submitSalvationAuditBatch")
    @ApiOperation("批量上报")
    public void submitSalvationAuditBatch(@RequestPart List<String> orderIdList) {
        log.info("批量上报，参数是：{}", orderIdList);
        Map<String, List<String>> stringListMap = tempBackLogService.exceBatchReport(orderIdList,getCurUserAccount());
        if(stringListMap.isEmpty()){
            setData("success");
        }else{
            setData("用户【"+String.join("," , stringListMap.get("noExistState"))+"】状态不是待上报，不能操作");
        }
        log.info("批量上报，结果是：{}", stringListMap);
    }



    @PostMapping("submitSalvationAudit")
    @ApiOperation("上报")
    public void submitSalvationAudit(@V({"notnull"}) String orderId) {
        log.info("上报，参数是：{}", orderId);
        Map<String, List<String>> stringListMap = tempBackLogService.exceBatchReport(new ArrayList<String>(){{add(orderId);}},getCurUserAccount());
        if(stringListMap.isEmpty()){
            setData("success");
        }else{
            setData("家庭【"+String.join("," , stringListMap.get("noExistState"))+"】状态不是待上报，不能操作");
        }
        //setData("用户【"+String.join("," , stringListMap.get("noExistState"))+"】状态不对，不能操作");
        log.info("上报，结果是：{}", stringListMap);
    }






    @PostMapping("getSalvationPrintReport")
    @ApiOperation("查询救助打印书信息")
    public void getSalvationPrintReport(@V("notnull") String orderId) {

    }


















    @PostMapping("cancelSalvationRequest")
    @ApiOperation("撤销救助申请")
    public void cancelSalvationRequest(@RequestPart List<String> orderIdList) {
        log.info("撤销救助申请，参数是：{}", orderIdList);
        Map<String, List<String>> stringListMap = tempBackLogService.cancelSalvationRequestTowns(orderIdList, getCurUserAccount());
        if(stringListMap.isEmpty()){
            setData("success");
        }else{
            setData("用户【"+String.join("," , stringListMap.get("noExistState"))+"】状态无法删除");
        }
        log.info("撤销救助申请，结果是：{}", stringListMap);
    }







    @PostMapping("getCountySalvationTodoList")
    @ApiOperation("获取区县待办列表")
    public void getCountySalvationTodoList(TemporaryOrderParam param, PageParam pageParam){

        UserAccountVo userAccountVo = getCurUserAccount();

        param.setBusinessType(Constant.BusinessCode.LINSHI);

        Page page = tmpOrderReadService.getNoFinishOrderCounty(param, pageParam, userAccountVo);
        this.setPageBean(page);
    }


    @PostMapping("sendCheckCounty")
    @ApiOperation("区县发起核对")
    public void sendCheckCounty(@V("notnull")  @RequestPart List<CheckDTO> checkDTOList){
        log.info("发起核对，参数是：{}", checkDTOList);
        Map<String, List<String>> rstMap = tempBackLogService.sendCheckCounty(checkDTOList, getCurUserAccount(), Constant.BusinessCode.LINSHI);
        setData(this.packageSendCheckRst(rstMap));
        log.info("发起核对，结果是：{}", rstMap);
    }


    @PostMapping("saveInHouseRecordCounty")
    @ApiOperation("保存入户调查信息")
    public void saveInHouseRecordCounty(OrderInHouseDTO orderInHouse, @RequestPart List<String> orderCertIdList){
        log.info("保存入户调查信息，参数是：{}", orderInHouse);
        orderInHouse.setCheckResult(Constant.BusinessCode.LINSHI);
        String inHouseId = tempBackLogService.saveInHouseRecord(orderInHouse, orderCertIdList, getCurUserAccount(),"0");
        setData(inHouseId);
        log.info("保存入户调查信息，结果是：{}", inHouseId);
    }


    @PostMapping("confirmInHouseRecordCounty")
    @ApiOperation("确认入户调查信息")
    public void confirmInHouseRecordCounty(OrderInHouseDTO orderInHouse){
        log.info("确认入户调查信息，参数是：{}", orderInHouse);
        orderInHouse.setCheckResult(Constant.BusinessCode.LINSHI);
        String inHouseId = tempBackLogService.saveInHouseRecord(orderInHouse, null, getCurUserAccount(),"1");
        setData(inHouseId);
        log.info("确认入户调查信息，结果是：{}", inHouseId);
    }


    @PostMapping("confirmUnfinshCheck")
    @ApiOperation("判断是否有核对未完成记录")
    public void confirmUnfinshCheck(@V("notnull") String orderId){
        log.info("判断是否有核对未完成记录,参数：{}",orderId);
        int i = checkReadService.isReturnCheckFile(orderId);
        setData(i);
        log.info("判断是否有核对未完成记录.结果是：{}",i);
    }


    @PostMapping("issueOrder")
    @ApiOperation("下发业务到乡镇")
    public void issueOrder(@RequestPart List<String> orderIdList, @RequestPart List<String> idcardAllList){
        log.info("下发业务到乡镇，参数是：{}", orderIdList);
        Map<String, List<String>> stringObjectMap = tempBackLogService.issueOrder(orderIdList, idcardAllList);
        if(null == stringObjectMap || stringObjectMap.isEmpty()){
            setData("操作成功");
        }else{
            StringBuffer rstMsg = new StringBuffer();
            rstMsg.append("身份证【").append(String.join("," , stringObjectMap.get("noExist"))).append("】，当前状态不可以被下发");
            setData(rstMsg);
        }
        log.info("下发业务到乡镇，结果是：{}", stringObjectMap);
    }


    @PostMapping("getApproval")
    @ApiOperation("得到对应的审批信息")
    public void getApproval(@V("notnull") String familyId, @V("notnull") String orderId){
        log.info("得到对应的审批信息，参数是：{}", orderId);
        TmpApprovalDTO tmpApprovalDTO = tempBackLogService.getApproval(familyId, orderId);
        setData(tmpApprovalDTO);
        log.info("得到对应的审批信息，结果是：{}", tmpApprovalDTO);
    }


    @CheckOrderUse(value = 0,type = "object",notes = "保存审批结果")
    @PostMapping("saveApproval")
    @ApiOperation("保存审批结果")
    public void saveApproval(@RequestBody TmpOrderDetailEntity orderDetailEntity){
        log.info("保存审批结果，参数是：{}", orderDetailEntity);
        tempBackLogService.saveApproval(orderDetailEntity, getCurUserAccount());
        setData(true);
        log.info("保存审批结果，结果是：{}", true);
    }


    @CheckOrderUse(value = 0,type = "object",notes = "确认审批结果")
    @PostMapping("confirmApproval")
    @ApiOperation("确认审批结果")
    public void confirmApproval(@RequestBody TmpOrderDetailEntity orderDetailEntity){
        log.info("确认审批结果，参数是：{}", orderDetailEntity);
        orderDetailEntity.setBusinessType(Constant.BusinessCode.LINSHI);
        String remindBankInfo = tempBackLogService.confirmApproval(orderDetailEntity, getCurUserAccount());
        setData(remindBankInfo);
        log.info("确认审批结果，结果是：{}", true);
    }



    @PostMapping("completeCheck")
    @ApiOperation("完成核对，修改状态")
    public void completeCheck(@RequestPart List<String> orderIdList){
        log.info("完成核对，修改状态：{}", orderIdList);
        checkWriteService.completeCheck(orderIdList);
        log.info("完成核对，修改状态：结果：{}", true);
    }

    @PostMapping("isCanUploadCheckFile")
    @ApiOperation("是否可以上传核对文件")
    public void isCanUploadCheckFile(String familyId,String orderId){
        log.info("是否可以上传核对文件,参数是{},{}",familyId,orderId);
        tempBackLogService.isCanUploadCheckFile(familyId,orderId);
        log.info("是否可以上传核对文件：{}",1);
    }


    @PostMapping("changeFamilySave")
    @ApiOperation("修改保障对象")
    public void changeFamilySave(String orderId,String familyId,String memberId,String type,String isMaster){
        log.info("修改保障对象，参数是orderSalary：{}", memberId);
        int rstMsg = tempBackLogService.chengeMemberSaveObject(orderId,familyId,memberId,type,isMaster);
        setData(rstMsg);
        log.info("修改保障对象，结果是：{}", rstMsg);
    }

    @PostMapping("uploadCheckFile")
    @ApiOperation("上传核对文件")
    public void uploadCheckFile(@RequestParam("file") MultipartFile[] file, String orderId,String reason){
        log.info("上传核对文件,参数是{}",orderId);
        int rst = tempBackLogService.uploadCheckFile(file,orderId,reason,getCurUserAccount().getAreaCode());
        log.info("上传核对文件,结果是：{}",rst);
    }


    @PostMapping("repealCheck")
    @ApiOperation("终止核对")
    public void repealCheck(@V("notnull") String checkId){
        log.info("终止核对,参数是{}",checkId);
        int rst = recheckService.repealCheck(checkId,getCurUserAccount());
        setData(rst);
        log.info("终止核对,结果是：{}",rst);
    }


    @PostMapping("downLoadTownSalvation")
    @ApiOperation(value="导出临时救助乡镇已办信息", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,notes="导出临时救助乡镇待办信息")
    public void downLoadTownSalvation(HttpServletResponse response, @RequestBody TemporaryOrderParam param)throws IOException {
        log.info("开始导出临时救助乡镇已办信息，参数是：{}", param);
        param.setBusinessType(Constant.BusinessCode.LINSHI);
        param.setRecordFlag("'01','03'");
        ExcelInfo excelInfo = tempBackLogService.exportExcelSave(param,getCurUserAccount());
        if(null != excelInfo){
            FileExportUtil.exportFileResponse(response, excelInfo, getCurUserAccount().getAreaName());
//            ZipInfoUtil.exportZipResponse(response, excelInfo, this.getCurUserId());
        }
        log.info("开始导出临时救助乡镇已办信息，查询结果是：{}", excelInfo);
    }


    @PostMapping("downLoadCountySalvation")
    @ApiOperation(value="导出临时救助区县已办信息", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,notes="导出临时救助区县待办信息")
    public void downLoadCountySalvation(HttpServletResponse response, @RequestBody TemporaryOrderParam param)throws IOException {
        log.info("开始导出临时救助区县已办信息，参数是：{}", param);
        param.setBusinessType(Constant.BusinessCode.LINSHI);

        ExcelInfo excelInfo = tempBackLogService.exportExcelSave(param,getCurUserAccount());
        if(null != excelInfo){
            FileExportUtil.exportFileResponse(response, excelInfo, getCurUserAccount().getAreaName());
//            ZipInfoUtil.exportZipResponse(response, excelInfo, this.getCurUserId());
        }
        log.info("开始导出临时救助区县已办信息，查询结果是：{}", excelInfo);
    }


    @PostMapping("sendBackSys")
    @ApiOperation("发起退回")
    public void sendBackSys(@V("notnull") String orderId,String content){
        log.info("发起退回，参数是：{}", orderId);
        tempBackLogService.sendBackSys(orderId, content, getCurUserAccount(), Constant.BusinessCode.LINSHI);
        setData(true);
    }


    @PostMapping("deleteSelectRecord")
    @ApiOperation("删除救助申请")
    public void deleteSelectRecord(@V("notnull") String orderId) {
        log.info("删除救助申请，参数是：{}", orderId);
        tempBackLogService.deleteSelectRecord(orderId);
        log.info("删除救助申请成功");
        setData(true);
    }
}
